<?php
//Start session
session_start();

//Include database connection details
require_once('../../inc/config.inc');

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

if(isset($_GET['today'])){
$qry= mysql_query("SELECT * FROM appointments WHERE `date`='".$_GET['date']."' && b_user= '".$_GET['b_user']."' ");
if(mysql_num_rows($qry) < 1){
	echo "No appointments were found in this date.";
	exit();
}
while($row=mysql_fetch_array($qry)){
	$qrytype=mysql_query("SELECT * FROM appointment_types WHERE id='".$row['a_type_id']."'");
	$rowtype=mysql_fetch_array($qrytype);
	?>
	<p class="alert alert-info">
					<?php echo $row['time']; ?> - <?php echo $rowtype['name']; ?><span class="pull-right"><a href="javascript:void()" class="cancel_a" id="<?php echo $row['id']; ?>">Cancel</a></span>
				</p>
	<?php
}
}
else{
	echo $_GET['today'];
}